package com.river.boot.biz.model.entity;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import com.baomidou.mybatisplus.annotation.TableName;
import com.river.boot.common.base.BaseEntity;

/**
 * 菜品实体对象
 *
 * @author JiangCheng Xiang
 * @since 2025-04-24 21:04
 */
@Getter
@Setter
@TableName("biz_product")
public class Product extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 店铺ID
     */
    private Long shopId;
    /**
     * 分类ID
     */
    private Long categoryId;
    /**
     * 菜品名称
     */
    private String name;
    /**
     * 菜品描述
     */
    private String description;
    /**
     * 主图URL
     */
    private String mainImage;
    /**
     * 多图URL数组
     */
    private String imageList;
    /**
     * 现价
     */
    private BigDecimal price;
    /**
     * 原价
     */
    private BigDecimal originalPrice;
    /**
     * 成本价
     */
    private BigDecimal costPrice;
    /**
     * 库存(-1表示无限)
     */
    private Integer stock;
    /**
     * 销量
     */
    private Integer sales;
    /**
     * 标签数组['招牌','辣']
     */
    private String tags;
    /**
     * 排序权重
     */
    private Integer sort;
    /**
     * 状态：1-上架 0-下架
     */
    private Integer status;

    public void imageList(List<String> imageList) {
        if (Objects.isNull(imageList)) return;
        this.imageList = JSONUtil.toJsonStr(imageList);
    }

    public List<String> imageList() {
        if (Objects.isNull(imageList)) return null;
        return JSONUtil.toList(imageList, String.class);
    }

    public void tags(List<String> tags) {
        if (Objects.isNull(tags)) return;
        this.tags = JSONUtil.toJsonStr(tags);
    }

    public List<String> tags() {
        if (Objects.isNull(tags)) return null;
        return JSONUtil.toList(tags, String.class);
    }
}
